import { ref } from 'vue'
import { defineStore } from 'pinia'
import { getLocation, getHttpCityList } from '../api/getdata'
export const useCityStore = defineStore('city', () => {
  const city = ref('')
  const cities = ref({})
  const hotCities = ref([])
  function getPositionHttp() {
    getLocation().then((res) => {
      city.value = res.data.city
    })
  }
  function getCityList() {
    getHttpCityList().then((res) => {
      hotCities.value=res.data.data.hotCities
      cities.value = res.data.data.cities
    })
  }
  return { city, getPositionHttp, getCityList, cities,hotCities}
})
